package com.liruo.treasureattic.service.user.mapper;

import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author:liruo
 * @Date:2022-10-28-23:54:31
 * @Desc
 */
public interface FollowMapper {
    @Insert("insert into `ta_user_follow` (`follower_id`, `follow_id`) value (#{followerId}, #{followId})")
    @ResultType(Boolean.class)
    Boolean follow(@Param("followerId") Long followerId, @Param("followId")Long followId);

    @Select("select count(`follower_id`) > 0 from `ta_user_follow` where `follower_id` = #{followerId} and `follow_id` = #{followId}")
    @ResultType(Boolean.class)
    Boolean isFollow(@Param("followerId") Long followerId, @Param("followId")Long followId);

    @Delete("delete from `ta_user_follow` where `follower_id` = #{followerId} and `follow_id` = #{followId}")
    @ResultType(Boolean.class)
    Boolean unfollow(@Param("followerId") Long followerId, @Param("followId")Long followId);

    @Select("select `follow_id` from `ta_user_follow` where `follower_id` = #{followerId}")
    @ResultType(List.class)
    List<Long> getFollowings(@Param("followerId") Long followerId);

    @Select("select `follower_id` from `ta_user_follow` where `follow_id` = #{followId}")
    @ResultType(List.class)
    List<Long> getFollowers(@Param("followId")Long followId);

}
